import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

let defaultCity = '汕头'

try{
  if(localStorage.city){
    defaultCity = localStorage.city;
  }
}catch(e){}


export default new Vuex.Store({
  // 存放全局公用的数据
  state: {
      city:defaultCity
  },
  mutations: {
    changeCity(state,city){
        state.city = city
        try{
           localStorage.city = city
        }catch (e) {

        }

    }
  },
  actions: {
    changeCity(ctx,city){
        ctx.commit('changeCity',city)
    }
  },
  modules: {

  }
})
